//
//  HTStates.swift
//  weibo
//
//  Created by JonsonLiu on 2017/3/3.
//  Copyright © 2017年 JonsonLiu. All rights reserved.
//

import UIKit

class HTStates: NSObject {

    var id : Int = 0
    var text: String?
    var user: HTUser?
    var retweeted_status: HTStates?
    var pic_urls : [HTStatesPicture]?
    /// 转发数
    var reposts_count: Int = 0
    /// 评论数
    var comments_count: Int = 0
    /// 点赞数
    var attitudes_count: Int = 0
    
    

    init(dict: [String: AnyObject?]) {

        super.init()

        setValuesForKeys(dict)


    }

    
    
    override func setValue(_ value: Any?, forKey key: String) {
        if key == "user" {

            guard let dict = value as? [String: AnyObject] else {

                return
            }

            user = HTUser(dict: dict)
        } else if key == "retweeted_status" {
            guard let dict = value as? [String: AnyObject] else {
                return
            }
            retweeted_status = HTStates(dict: dict)

        }
        else if key == "pic_urls"{
        
            guard let dict = value as? [[String: AnyObject]] else {
                return
            }
            
           var tempArray = [HTStatesPicture]()
            for dict in dict {
                let info = HTStatesPicture(dict: dict)
                tempArray.append(info)
                
            }
            pic_urls = tempArray
        }
        else{
            super.setValue(value, forKey: key)
        }
    }

    override func setValue(_ value: Any?, forUndefinedKey key: String) {

    }
    
    override var description: String  {
        return yy_modelDescription()
    }
    
    class func modelContainerPropertyGenericClass() -> [String: AnyClass] {
        return ["pic_urls": HTStatesPicture.self]
    }

}
